<template>
	<el-container>
		<el-header>
			<div class="left-panel">
				<sc-export-button :apiObj="apiObj" :search="search"></sc-export-button>
			</div>
			<div class="right-panel">
				<div class="right-panel-search">
                    <el-select v-model="search.ware_id" filterable placeholder="仓库" @change="inChange" clearable>
                        <el-option v-for="item in wareList" :key="item.id" :label="item.ware_name" :value="item.id" />
                    </el-select>
					<el-input v-model="search.goods_name" placeholder="产品型号" clearable @keyup.enter="upsearch"></el-input>
					<!-- <el-input v-model="search.goods_code" placeholder="产品编号" clearable @keyup.enter="upsearch"></el-input> -->
					<el-button type="primary" icon="el-icon-search" @click="upsearch"></el-button>
				</div>
			</div>
		</el-header>
		<el-main class="nopadding">
			<scTable ref="table" :apiObj="apiObj" row-key="id" @selection-change="selectionChange" stripe border>
				<el-table-column type="selection" width="50"></el-table-column>
				<el-table-column label="#" type="index" width="50" align="center"></el-table-column>
                    <el-table-column label="关联单号" prop="order_no" align="center"></el-table-column>
                    <el-table-column label="颜色" prop="color_name" align="center"></el-table-column>
                    <el-table-column label="方向" prop="direction_name" align="center"></el-table-column>
					<el-table-column label="产品型号" prop="goods.goods_model" align="center"></el-table-column>
					<el-table-column label="速比" prop="goods.speed_ratio.name" align="center" width="100"></el-table-column>
					<el-table-column label="法兰" prop="goods.flange.name" align="center" width="100"></el-table-column>
					<el-table-column label="孔数" prop="goods.hole" align="center" width="100"></el-table-column>
                    <el-table-column label="仓库" prop="ware.ware_name" align="center"></el-table-column>
                    <el-table-column label="变动类型" prop="change_type" align="center" width="100"></el-table-column>
                    <el-table-column label="变动前库存数" prop="before" align="center"></el-table-column>
                    <el-table-column label="变动库存数" prop="stock" align="center"></el-table-column>
                    <el-table-column label="变动后库存数" prop="after" align="center"></el-table-column>
                    <el-table-column label="变动类型" prop="type" align="center" width="100">
                        <template #default="scope">
                            <el-tag :type="scope.row.type == 1?'success':'danger'">
                                {{scope.row.type == 1?'增加':'减少'}}
                            </el-tag>
                        </template>
                    </el-table-column>
                    <el-table-column label="变动时间" prop="create_time" align="center"></el-table-column>
                    <el-table-column label="操作人" prop="changer.name" align="center" width="100"></el-table-column>
			</scTable>
		</el-main>
	</el-container>

	<save-dialog v-if="dialog.save" ref="saveDialog" @success="handleSaveSuccess" @closed="dialog.save=false"></save-dialog>

</template>

<script>
	import saveDialog from './save'

	export default {
		name: '查询1',
		components: {
			saveDialog
		},
		data() {
			return {
				dialog: {
					save: false
				},
				apiObj: this.$API.ware.history,
				selection: [],
				search: {
					ware_id: null
				},
                wareList:[],
			}
		},
        mounted() {
            this.getWare()
		},
		methods: {
			//表格选择后回调事件
			selectionChange(selection){
				this.selection = selection;
			},
			//搜索
			upsearch(){
				this.$refs.table.upData(this.search)
			},
            // 获取仓库
            async getWare(){
                var res = await this.$API.goods.ware.all.get();
                this.wareList = res.data;
            },
		}
	}
</script>

<style>
</style>
